package com.cy.personer.test;


import com.cy.personer.bean.Remark;
import com.cy.personer.bean.Report;
import com.cy.personer.bean.ReportItem;
import com.cy.personer.bean.ReportitemDetail;
import com.cy.personer.mapper.RemarkMapper;
import com.cy.personer.mapper.ReportDetailSxbMapper;
import com.cy.personer.mapper.ReportSxbMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)//第一个是初始化测试环境
@ContextConfiguration("classpath:applicationContext.xml")//第二个是加载Spring配置文件，这个用来初始化测试容器
//@Transactional("transactionManager")
//@Rollback(false)
public class test {
    @Resource
    private RemarkMapper remarkMapper;
    @Resource
    private Remark remark;
    @Resource
    private ReportSxbMapper reportSxbMapper;
    @Resource
    private Report report;
    @Resource
    private ReportDetailSxbMapper reportDetailSxbMapper ;
    @Test
    public void getRetportItem(){
        List<ReportItem> reportItems = reportSxbMapper.reportItemByWorkId(124);
        for (int i=0;i<reportItems.size();i++){
            System.out.println("******"+reportItems.get(i).getItem().getItemMoney());
        }

    }

@Test
public  void queryReportDetails(){
    List<ReportitemDetail> reportitemDetails = reportDetailSxbMapper.reportDetails(42);
    System.out.println(reportitemDetails.size());
    for(int i=0;i<reportitemDetails.size();i++){
        System.out.println(reportitemDetails.get(i).getDetail().getDetailName());
    }
}

@Test
public  void reportInformation(){
    List<ReportItem> reportItems = reportSxbMapper.reportInformation(281);
    for(int i=0;i<reportItems.size();i++){
        System.out.println( reportItems.get(i).getItem().getItemMoney());
    }

}

@Test
public void updateItemState(){
    boolean b = reportSxbMapper.updateReportItemId(42, 17);
    System.out.println(b);
}
//    @Test
//    public void queryReport(){
//        List<ReportItem> reportItems = reportSxbMapper.reportItemListSxb(1, 148, 17);
//        System.out.println(reportItems.size());
//        for (int i=0;i<reportItems.size();i++){
//            System.out.println(reportItems.get(i).getItem().toString());
//            System.out.println(reportItems.get(i).getState().toString());
//            System.out.println(reportItems.get(i).getDesk().toString());
//
//        }
//
//    }

//    @Test
//    public void testMyBatis() {
////        int i=10;
////        PageHelper.startPage(i, 2);
////        List<Remark> remarks = remarkMapper.remarkList();
////        PageInfo<Remark> page = new PageInfo<>(remarks);
////        int nextPage = page.getNextPage();
////        System.out.println(nextPage);
//        List<Remark> remarks = remarkMapper.remarkList();
//for (int i=0;i<remarks.size();i++){
//       System.out.println("----="+remarks.get(i).toString());
//
//}
//
//    }

    @Test
    public void delRemark(){
        boolean b = remarkMapper.delRemark(6);
        System.out.println(b);
    }
    @Test
    public void queryById(){
        Remark remark = remarkMapper.queryRemark(1);
        System.out.println("111111"+remark.getWork().getDesk().getDeskName());

    }

@Test
    public void sy (){
        Integer a=null;
    System.out.println(a);
}
}
